package vista;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Enumeration;

import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;

import controlador.BotonEmitirOrdenListener;

//import controlador.EmitirOrdenListener;


public class PanelOeste extends Paneles {
	
	
	private static final long serialVersionUID = 1L;
	
	JLabel explicacionComisaria;

	
	JButton emitirOrden;

	JRadioButton cabello1, cabello2, cabello3, cabello4;
	JRadioButton hobby1, hobby2, hobby3, hobby4, hobby5, hobby6;
	JRadioButton senia1, senia2, senia3, senia4;
	JRadioButton sexo1, sexo2;
	JRadioButton vehic1, vehic2, vehic3, vehic4;
	
	ButtonGroup grupoCabello;
	ButtonGroup grupoHobby;
	ButtonGroup grupoSenia;
	ButtonGroup grupoSexo;
	ButtonGroup grupoVehiculo;
	
	JLabel cabello;
	JLabel hobby;
	JLabel senia;
	JLabel sexo;
	JLabel vehiculo;
	
	
	public PanelOeste(Ventana ventana) {
		super(ventana, "/imagenes/comisaria.gif");
		setLayout(new GridBagLayout());
		
		explicacionComisaria = new JLabel ("Indique las caracteristicas del sospechoso "
				+ "y luego envie la orden de arresto. Enviarla toma 3 horas.");
		
		emitirOrden = new JButton ("Emitir Orden");
		
		cabello = new JLabel ("Cabello:");
		cabello.setForeground(Color.WHITE);
		hobby = new JLabel ("Hobby:");
		hobby.setForeground(Color.WHITE);
		senia = new JLabel ("Senia:");
		senia.setForeground(Color.WHITE);
		sexo = new JLabel ("Sexo:");
		sexo.setForeground(Color.WHITE);
		vehiculo = new JLabel ("Vehiculo:");
		vehiculo.setForeground(Color.WHITE);

		cabello1 = new JRadioButton("Castanio  ");
		cabello1.setForeground(Color.WHITE);
		cabello1.setOpaque(false);
		cabello2 = new JRadioButton("Rubio          ");
		cabello2.setForeground(Color.WHITE);
		cabello2.setOpaque(false);
		cabello3 = new JRadioButton("Rojo               ");
		cabello3.setForeground(Color.WHITE);
		cabello3.setOpaque(false);
		cabello4 = new JRadioButton("Negro               ");
		cabello4.setForeground(Color.WHITE);
		cabello4.setOpaque(false);
		
		grupoCabello = new ButtonGroup();
		
		grupoCabello.add(cabello1);
		grupoCabello.add(cabello2);
		grupoCabello.add(cabello3);
		grupoCabello.add(cabello4);
		
		hobby1 = new JRadioButton("Tenis         ");
		hobby1.setForeground(Color.WHITE);
		hobby1.setOpaque(false);
		hobby2 = new JRadioButton("Musica      ");
		hobby2.setForeground(Color.WHITE);
		hobby2.setOpaque(false);
		hobby3 = new JRadioButton("Alpinismo   ");
		hobby3.setForeground(Color.WHITE);
		hobby3.setOpaque(false);
		hobby4 = new JRadioButton("Paracaidismo");
		hobby4.setForeground(Color.WHITE);
		hobby4.setOpaque(false);
		hobby5 = new JRadioButton("Natacion ");
		hobby5.setForeground(Color.WHITE);
		hobby5.setOpaque(false);
		hobby6 = new JRadioButton("Croquet ");
		hobby6.setForeground(Color.WHITE);
		hobby6.setOpaque(false);
		
		grupoHobby = new ButtonGroup();
		
		grupoHobby.add(hobby1);
		grupoHobby.add(hobby2);
		grupoHobby.add(hobby3);
		grupoHobby.add(hobby4);
		grupoHobby.add(hobby5);
		grupoHobby.add(hobby6);
		
		senia1 = new JRadioButton("Anillo           ");
		senia1.setForeground(Color.WHITE);
		senia1.setOpaque(false);
		senia2 = new JRadioButton("Tatuaje      ");
		senia2.setForeground(Color.WHITE);
		senia2.setOpaque(false);
		senia3 = new JRadioButton("Cicatriz       ");
		senia3.setForeground(Color.WHITE);
		senia3.setOpaque(false);
		senia4 = new JRadioButton("Joyas              ");
		senia4.setForeground(Color.WHITE);
		senia4.setOpaque(false);
		
		grupoSenia = new ButtonGroup();
		
		grupoSenia.add(senia1);
		grupoSenia.add(senia2);
		grupoSenia.add(senia3);
		grupoSenia.add(senia4);
		
		sexo1 = new JRadioButton("Masculino   ");
		sexo1.setForeground(Color.WHITE);
		sexo1.setOpaque(false);
		sexo2 = new JRadioButton("Femenino ");
		sexo2.setForeground(Color.WHITE);
		sexo2.setOpaque(false);
		
		grupoSexo = new ButtonGroup();
		
		grupoSexo.add(sexo1);
		grupoSexo.add(sexo2);
		
		vehic1 = new JRadioButton("Descapotable");
		vehic1.setForeground(Color.WHITE);
		vehic1.setOpaque(false);
		vehic2 = new JRadioButton("Limusina    ");
		vehic2.setForeground(Color.WHITE);
		vehic2.setOpaque(false);
		vehic3 = new JRadioButton("Deportivo   ");
		vehic3.setForeground(Color.WHITE);
		vehic3.setOpaque(false);
		vehic4 = new JRadioButton("Moto           ");
		vehic4.setForeground(Color.WHITE);
		vehic4.setOpaque(false);
		
		grupoVehiculo = new ButtonGroup();
		
		grupoVehiculo.add(vehic1);
		grupoVehiculo.add(vehic2);
		grupoVehiculo.add(vehic3);
		grupoVehiculo.add(vehic4);
		
		GridBagConstraints gbc = new GridBagConstraints();
		
		gbc.insets = new Insets(3,3,3,3);
		
		gbc.gridx = 0;
		gbc.gridy = 0;
		
		this.add(cabello,gbc);
		
		gbc.gridx = 1;
		gbc.gridy = 1;
		this.add(cabello1,gbc);
		gbc.gridx = 2;
		this.add(cabello2,gbc);
		gbc.gridx = 3;
		this.add(cabello3,gbc);
		gbc.gridx = 4;
		this.add(cabello4,gbc);
	
		
		gbc.gridx = 0;
		gbc.gridy = 2;
		
		this.add(hobby,gbc);
		
		gbc.gridy = 3;
		gbc.gridx = 1;
		this.add(hobby1,gbc);
		gbc.gridx = 2;
		this.add(hobby2,gbc);
		gbc.gridx = 3;
		this.add(hobby3,gbc);
		gbc.gridx = 4;
		this.add(hobby4,gbc);
		gbc.gridx = 5;
		this.add(hobby5,gbc);
		gbc.gridx = 6;
		this.add(hobby6,gbc);
		
		gbc.gridx = 0;
		gbc.gridy = 4;
		
		this.add(senia,gbc);
		
		gbc.gridy = 5;
		gbc.gridx = 1;
		this.add(senia1,gbc);
		gbc.gridx = 2;
		this.add(senia2,gbc);
		gbc.gridx = 3;
		this.add(senia3,gbc);
		gbc.gridx = 4;
		this.add(senia4,gbc);
		
		gbc.gridx = 0;
		gbc.gridy = 6;
		
		this.add(sexo,gbc);
		
		gbc.gridy = 7;
		gbc.gridx = 1;
		this.add(sexo1,gbc);
		gbc.gridx = 2;
		this.add(sexo2,gbc);
		
		gbc.gridx = 0;
		gbc.gridy = 8;
		
		this.add(vehiculo,gbc);

		gbc.gridy = 9;
		gbc.gridx = 1;
		this.add(vehic1,gbc);
		gbc.gridx = 2;
		this.add(vehic2,gbc);
		gbc.gridx = 3;
		this.add(vehic3,gbc);
		gbc.gridx = 4;
		this.add(vehic4,gbc);
		
		gbc.gridx=4;
		gbc.gridy=10;
		this.add(emitirOrden,gbc);
		
		setVisible (false);
		setOpaque(false);
	}	
	
	public void cambiarVisibilidadACiudad() {
		this.setVisible(false);
	}
	
	public void cambiarVisibilidadAComisaria() {
		this.setVisible(true);
		JOptionPane.showMessageDialog(null, "Indique las caracteristicas del sospechoso y luego envie la orden de arresto");
	}
	
	public void cambiarVisibilidadADestinos() {
		this.setVisible(false);
	}

	public void cambiarVisibilidadAMenuPrincipal() {
		this.setVisible(false);
	}
	
	public JRadioButton getBotonSeleccionadoCabello() {
		return this.devolverBotonSeleccionado(grupoCabello);
	}
	
	public JRadioButton getBotonSeleccionadoHobby(){
		return this.devolverBotonSeleccionado(grupoHobby);
	}
	
	public JRadioButton getBotonSeleccionadoSexo(){
		return this.devolverBotonSeleccionado(grupoSexo);
	}
	
	public JRadioButton getBotonSeleccionadoVehiculo(){
		return this.devolverBotonSeleccionado(grupoVehiculo);
	}
	
	public JRadioButton getBotonSeleccionadoSenia(){
		return this.devolverBotonSeleccionado(grupoSenia);
	}
	
	//Metodo para obtener el boton seleccionado de un grupo de botones.
	public JRadioButton devolverBotonSeleccionado (ButtonGroup grupoBotones){
		for (Enumeration<AbstractButton> botones = grupoBotones.getElements(); botones.hasMoreElements();)
		{
			JRadioButton boton = (JRadioButton) botones.nextElement();
			if (boton.isSelected()){
				return boton;
			}
		}
		return null;
	}
	
	public void addEmitirOrdenListener(BotonEmitirOrdenListener emitirOrdenListener) {
		emitirOrden.addActionListener(emitirOrdenListener);
	}
}
